Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 6 - Expressions / Operations
Operators That Handle Operands of Various Classes


Starts With, Ends With

The Starts With and Ends With operators work with lists and strings.

LIST
A list starts with another list if the values of the items in the list to the right of the operator are equal to the values of the items at the beginning of the list to the left. A list ends with another list if the values of the items in the list to the right of the operator are equal to the values of the items at the end of the list to the left. In both cases, the items in the two lists must be in the same order. Both Starts With and Ends With work if the operand to the right of the operator is a single value. For example,

{ "this", "is", 2, "cool" } ends with "cool"
and

{ "this", "is", 2, "cool" } starts with "this"
and

{ "this", "is", 2, "cool" } starts with { "this", "is" }
are all true.

STRING
A string starts with another string if the characters in the string to the right of the operator are the same as the characters at the beginning of the string to the left. For example,

"operand" starts with "opera"
is true.

A string ends with another string if the characters in the string to the right of the operator are the same as the characters at the end of the string to the left. For example,

"operand" ends with "and"
is true.

AppleScript compares strings character by character according to the rules for the Equal operator.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996